<%-- 
/*
Assignment 1
Class ID        : SE0691
Group           : 1
Due Date        : 20 November 2012
I declare that this assignment is my own work
in accordance with FPT Policy.
*/
--%>

<%@page import="edu.fpt.hib.News"%>
<%@page import="edu.fpt.dal.NewsDAL"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Editing News</title>
        <style type="text/css"> <!--@import url("../style.css");--></style>
        <script>function goBack()  {  window.history.back()  }</script>
    </head>
    <body>
        <%@include file="template/header.jsp" %>
        <div id="page">

            <% try {
                    int id = Integer.parseInt(request.getParameter("newsid"));
                    if (NewsDAL.getNews(id) == null) {

            %>
            News not found!
            <% } else {
                News news = NewsDAL.getNews(id);
                if (request.getParameter("error") == null) {
            %>
            <h2 class="title">Editing of : <%=news.getNewsTitle()%></h2>
            <form method="post" action="../EditNews">
                <table border="0">
                    <tr>
                        <td>News ID:</td>
                        <td><input type="text" value="<%=news.getNewsId()%>" disabled="" name="newsid">
                            <input type="hidden" value="<%=news.getNewsId()%>" name="newsid"></td>
                    </tr>
                    <tr>
                        <td>Title</td>
                        <td><input type="text" value="<%=news.getNewsTitle()%>" name="title" required=""></td>
                    </tr>
                    <tr>
                        <td>Content</td>
                        <td><textarea value="<%=news.getNewsContent()%>" name="content" rows="15" style="width: 450px;"></textarea>
                            <input type="hidden" name="isEdit" value="change"></td>
                    </tr>

                </table>
                <input class="searchsubmit" type="submit" name="Change">
                <input class="searchsubmit" type="reset" name="Reset">
                <input class="searchsubmit" type='button' value='Back' onclick='goBack()'>
            </form>

            <%}
                    }
                } catch (Exception e) {
                    out.println(e.getMessage());
                }%>
        </div>
        <%@include file="template/footer.jsp" %>
    </body>
</html>
